<template>
  <el-form
    :model="noticForm"
    ref="noticForm"
    label-width="20px"
    :inline="true"
    :rules="rules"
  >
    <el-card>
      <h4 style="font-weight: 800">
        达人信息(第一行必填)<el-button
          type="primary"
          size="mini"
          plain
          icon="el-icon-plus"
          style="margin-left: 10px"
          @click="iscontactList = true"
          >达人联系信息</el-button
        >
        <el-button
          type="primary"
          size="mini"
          plain
          style="margin-left: 10px"
          @click="handleSampleInfo"
          >清空达人联系信息</el-button
        >
      </h4>
      <el-row>
        <el-form-item label="" prop="platform">
          <!-- <el-input v-model="sampleTalentInfo.platform" placeholder="请输入平台名称" /> -->
          <el-select
            :disabled="isEdit"
            v-model="sampleTalentInfo.platform"
            placeholder="平台名称"
            clearable
          >
            <el-option
              v-for="dict in dict.type.sys_sample_name"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label=" " prop="platformId">
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.platformId"
            placeholder="请输入平台ID"
          />
        </el-form-item>

        <el-form-item label=" " prop="xhsNickname">
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.xhsNickname"
            placeholder="请输入昵称"
          />
        </el-form-item>
        <br />
        <el-form-item label="" prop="talentLevel">
          <!-- <el-input v-model="sampleTalentInfo.talentLevel" placeholder="请输入达人层级" /> -->
          <el-select
            :disabled="isEdit"
            v-model="sampleTalentInfo.talentLevel"
            placeholder="达人层级"
            clearable
          >
            <el-option
              v-for="dict in dict.type.sys_sample_cj"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="contactPerson">
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.contactPerson"
            placeholder="请输入对接人"
          />
        </el-form-item>
        <el-form-item label="" prop="fansNum">
          <el-input
            :disabled="isEdit"
            type="number"
            v-model="sampleTalentInfo.fansNum"
            placeholder="请输入粉丝量(W)"
          />
        </el-form-item>
        <el-form-item label="" prop="likeNum">
          <el-input
            :disabled="isEdit"
            type="number"
            v-model="sampleTalentInfo.likeNum"
            placeholder="请输入赞藏量(W)"
          />
        </el-form-item>
        <el-form-item label="" prop="contactWechat">
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.contactWechat"
            placeholder="请输入联系方式"
          />
        </el-form-item>

        <el-form-item label="" prop="talentStatus">
          <!-- <el-input v-model="queryParams.platform" placeholder="请输入平台名称" clearable @keyup.enter.native="handleQuery" /> -->
          <el-select
            :disabled="isEdit"
            v-model="sampleTalentInfo.talentStatus"
            placeholder="状态"
            clearable
          >
            <el-option
              v-for="dict in dict.type.sys_sample_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="recommendSituation">
          <!-- <el-input v-model="form.recommendSituation" placeholder="请输入种草情况" /> -->
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.recommendSituation"
            placeholder="种草情况"
            type="textarea"
            :autosize="{ minRows: 1, maxRows: 12 }"
            style="width: 250px"
          />
        </el-form-item>
        <el-form-item label="" prop="reason">
          <!-- <el-input v-model="form.reason" placeholder="请输入理由" /> -->
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.reason"
            placeholder="理由"
            type="textarea"
            :autosize="{ minRows: 1, maxRows: 12 }"
            style="width: 250px"
          />
        </el-form-item>
        <el-form-item label="" prop="homeLink">
          <!-- <el-input v-model="form.homeLink" placeholder="请输入主页链接" /> -->
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.homeLink"
            placeholder="请输入主页链接"
            type="textarea"
            :autosize="{ minRows: 1, maxRows: 12 }"
            style="width: 250px"
          />
        </el-form-item>

        <el-form-item label="" prop="cooperatePrice">
          <!-- <el-input v-model="form.cooperatePrice" placeholder="请输入合作报价" /> -->
          <el-input
            :disabled="isEdit"
            v-model="sampleTalentInfo.cooperatePrice"
            placeholder="请输入合作报价"
            type="textarea"
            :autosize="{ minRows: 1, maxRows: 12 }"
            style="width: 250px"
          />
        </el-form-item>
      </el-row>
    </el-card>
    <el-dialog
      :visible.sync="iscontactList"
      width="95%"
      height="100%"
      append-to-body
      v-if="iscontactList"
    >
      <clickcontact @trackingNumberHandle="trackingNumberHandle" />
    </el-dialog>
    <el-card>
      <h4 style="font-weight: 800">收货信息(必填)</h4>
      <el-col :span="16" :xs="24">
        <el-row>
          <el-form-item label="收件人" prop="recipient" label-width="70px">
            <el-input
              :disabled="isEdit"
              v-model="sampleTalentContact.recipient"
              placeholder="请输入收件人"
            />
          </el-form-item>
          <el-form-item label="电话" prop="phone" label-width="50px">
            <el-input
              :disabled="isEdit"
              v-model="sampleTalentContact.phone"
              placeholder="请输入电话"
            />
          </el-form-item>

          <el-form-item
            label="所在地区"
            prop="receiverState"
            label-width="80px"
          >
            <!-- <el-input v-model="sampleTalentContact.receiverState" placeholder="--请选择省份--" /> -->
            <el-select
              :disabled="isEdit"
              v-model="sampleTalentContact.receiverState"
              clearable
              placeholder="省"
              @change="seletekey($event, 'province')"
              style="width: 150px"
            >
              <el-option
                v-for="(val, key) in provinces"
                :key="key"
                :label="val"
                :value="val"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="" prop="receiverCity" label-width="50px">
            <!-- <el-input v-model="sampleTalentContact.receiverCity" placeholder="--请选择城市--" /> -->
            <el-select
              :disabled="isEdit"
              v-model="sampleTalentContact.receiverCity"
              clearable
              placeholder="市"
              @change="seletekey($event, 'city')"
              style="width: 150px"
            >
              <el-option
                v-for="(val, key) in citys"
                :key="key"
                :label="val"
                :value="val"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="" prop="receiverDistrict">
            <!-- <el-input v-model="sampleTalentContact.receiverDistrict" placeholder="--请选择县区--" /> -->
            <el-select
              :disabled="isEdit"
              v-model="sampleTalentContact.receiverDistrict"
              clearable
              placeholder="县区"
              @change="seletekey($event, 'area')"
              style="width: 150px"
              filterable
              allow-create
            >
              <el-option
                v-for="(val, key) in areas"
                :key="key"
                :label="val"
                :value="val"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="详细地址" prop="address" label-width="80px">
            <el-input
              :disabled="isEdit"
              v-model="sampleTalentContact.address"
              placeholder="请输入详细地址"
              style="width: 300px"
            />
          </el-form-item>
          <el-form-item
            prop="expressCompany"
            label="快递公司:"
            label-width="90px"
          >
            <!-- <el-input v-model="expressCompany"></el-input> -->
            <el-select
              v-model="expressCompany"
              placeholder="请选择快递公司"
              clearable
              filterable
            >
              <el-option
                v-for="dict in dict.type.sys_jst_sample_sf"
                :key="dict.label"
                :label="dict.label"
                :value="dict.label"
              />
            </el-select>
          </el-form-item>
        </el-row>
      </el-col>

      <el-col :span="8" :xs="24">
        <el-form-item label="" prop="">
          <el-input
            :disabled="isEdit"
            v-model="demo"
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 10 }"
            placeholder="省市区地址、姓名、电话11位用空格分开!!"
            style="width: 400px"
          ></el-input>
          <el-button type="primary" size="mini" @click="addText"
            >识别</el-button
          >
          <!-- <el-input v-model="sampleTalentPay.platform" placeholder="请输入平台名称" /> -->
        </el-form-item>
      </el-col>
    </el-card>

    <!-- <el-row>
            <el-card>
                <el-form-item label="合作类型:" prop="platform" label-width="90px">
                    
                    <el-radio-group v-model="sampleTalentCooperateType" size="small" fill="#66b1ff"
                        @change="testsampleTalentCooperateType">

                        <el-radio :label="'note'">笔记合作</el-radio>
                        <el-radio :label="'live'">直播合作</el-radio>

                    </el-radio-group>
                </el-form-item>
                
            </el-card>
        </el-row> -->
    <el-card>
      <h4 style="font-weight: 800">
        直播间信息(非必填，假如为公司直播间申请，需要选择对应直播间)
      </h4>
      <el-radio-group v-model="liveRoomNameStatus" size="small" fill="#66b1ff">
        <el-radio :label="0">非直播间申请 </el-radio>
        <el-radio :label="1">直播间申请</el-radio>
      </el-radio-group>
      <el-select
        v-if="liveRoomNameStatus == 1"
        style="margin-left: 10px"
        v-model="liveRoomName"
        clearable
        placeholder="直播间名称"
        filterable
      >
        <el-option
          v-for="(val, key) in liveroomList"
          :key="key"
          :label="val.liveStreamRoom"
          :value="val.liveStreamRoom"
        />
      </el-select>
    </el-card>
    <el-dialog
      :visible.sync="isByProductNo"
      width="60%"
      append-to-body
      v-if="isByProductNo"
    >
      <byProductNo @getinventoryByProductNo="getinventoryByProductNo" />
    </el-dialog>

    <el-card>
      <h4 style="font-weight: 800">
        合作款式(必填)<el-button
          type="primary"
          size="mini"
          plain
          icon="el-icon-plus"
          style="margin-left: 10px"
          @click="isByProductNo = true"
          >根据款式添加</el-button
        >
        <el-button
          type="primary"
          size="mini"
          plain
          style="margin-left: 10px"
          @click="handleProductInfo"
          >清空合作款式信息</el-button
        >
      </h4>
      <el-col :span="20">
        <el-row
          v-for="(noticItem, index) in noticForm.noticConfig"
          :key="index"
        >
          <el-col
            :span="20"
            v-for="nameItem in noticItem.name"
            :key="nameItem.key"
          >
            <el-form-item prop="productNo" label=" ">
              <!-- <el-input v-model="nameItem.productNo"></el-input> -->
              <el-select
                :disabled="nameItem.isEdit"
                v-model="nameItem.productNo"
                clearable
                filterable
                remote
                :remote-method="getDatas"
                :loading="loading"
                placeholder="合作款式"
                @change="testAdd"
                style="width: 150px"
              >
                <el-option
                  v-for="item in options"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="colorProperty" label=" ">
              <!-- <el-input v-model="nameItem.colorProperty"></el-input> @focus="onFocus" remote
                :remote-method="getData"-->
              <el-select
                :disabled="nameItem.isEdit"
                ref="selectRef"
                v-model="nameItem.colorProperty"
                clearable
                filterable
                placeholder="颜色属性"
                @change="testColor"
                style="width: 200px"
              >
                <el-option
                  v-for="item in ColorLike"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="size" label=" ">
              <!-- <el-select v-model="nameItem.size" placeholder="尺寸" clearable>
                        <el-option v-for="dict in dict.type.sys_product_size" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select> -->
              <!-- <el-input v-model="nameItem.size"></el-input> -->
              <el-select
                :disabled="nameItem.isEdit"
                @focus="onFocus"
                v-model="nameItem.size"
                clearable
                filterable
                remote
                :remote-method="getSize"
                placeholder="尺寸"
                @change="testSize(nameItem)"
                style="width: 100px"
              >
                <el-option
                  v-for="item in sizeList"
                  :key="item.id"
                  :label="item.size"
                  :value="item.size"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item @focus="onFocus" prop="productNum" label=" ">
              <el-input
                v-model="nameItem.productNum"
                placeholder="数量"
                style="width: 100px"
                type="number"
                oninput="value=value.replace(/^0|[^0-9]/g,'')"
                @focus="testNum()"
              ></el-input>
            </el-form-item>

            <el-form-item prop="num" label="库存量:" label-width="70px">
              {{ nameItem.publicCanUseNum }}
              <!-- {{ sizeArr[nameItem.id] }} -->
            </el-form-item>
            <el-form-item prop="isReturn" label="是否归还" label-width="80px">
              <!-- <el-input v-model="nameItem.isReturn" placeholder=""></el-input> -->
              <el-radio-group
                v-model="nameItem.isReturn"
                size="small"
                fill="#66b1ff"
              >
                <el-radio :label="'是'">是</el-radio>
                <el-radio :label="'否'">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="10" v-for="(phoneItem, index) in noticItem.phone" :key="phoneItem.key">
                <el-form-item prop="phone" label="电话：">
                    <el-input v-model="phoneItem.value"></el-input>
                </el-form-item>
            </el-col> -->
          <el-col :span="4">
            <el-button type="primary" size="mini" @click="addDomain(noticItem)"
              >新增</el-button
            >
            <el-button
              type="danger"
              size="mini"
              @click.prevent="removeDomain(noticItem)"
              >删除</el-button
            >
            <!-- <el-button type="primary" size="mini" @click="getinventory">查询</el-button> -->
          </el-col>
        </el-row>
      </el-col>
    </el-card>
    <el-card>
      <h4 style="font-weight: 800">支付信息(非必填)</h4>

      <el-row :inline="true">
        <el-form-item label="支付方式" prop="payMethod" label-width="80px">
          <el-input
            v-model="sampleTalentPay.payMethod"
            placeholder="请输入支付方式"
          />
        </el-form-item>
        <el-form-item label="支付账号" prop="payAccount" label-width="80px">
          <el-input
            v-model="sampleTalentPay.payAccount"
            placeholder="请输入支付账号"
          />
        </el-form-item>
        <el-form-item label="姓名" prop="payName" label-width="60px">
          <el-input
            v-model="sampleTalentPay.payName"
            placeholder="请输入姓名"
          />
        </el-form-item>
      </el-row>
    </el-card>

    <el-form-item style="width: 100%; text-align: center">
      <!-- <el-button @click="submitnote('noticForm')" type="primary"
        >笔记合作</el-button
      > -->
      <el-button @click="submitlive('noticForm')" type="primary"
        >直播合作</el-button
      >
      <el-button @click="resetForm" style="margin-left: 10px"
        >一键清空</el-button
      >
    </el-form-item>
  </el-form>
</template>
<script>
import byProductNo from "./byProductNo.vue";
import clickcontact from "@/views/sample/contact/clickcontact.vue";
import AddressParse from "address-parse";
//数据获取
import { pcaa } from "area-data";
import axios from "axios";
const util = require("@/api/sample/util.js");
// import { province } from '@/api/sample/map'
import {
  listTemplate,
  getTemplate,
  delTemplate,
  addTemplate,
  updateTemplate,
  addTemplateAndSecondry,
  addProNoColorSize,
  productNoLike,
} from "@/api/product/template";
import {
  listSecondry,
  getSecondry,
  delSecondry,
  addSecondry,
  updateSecondry,
  getInfoByName,
  productNoColorLike,
  listAll,
  colorLike,
} from "@/api/product/secondry";
import {
  listSample,
  getSample,
  delSample,
  addSample,
  updateSample,
  SampleTalentFirstAdd,
  inventory,
  inventoryByProductNo,
} from "@/api/sample/sample";
import {
  listLiveroom,
  getLiveroom,
  delLiveroom,
  addLiveroom,
  updateLiveroom,
} from "@/api/sample/liveroom";
export default {
  name: "Ceshi",
  dicts: [
    "sys_product_qudao",
    "sys_product_size",
    "sys_product_coder",
    "sys_sample_sf",
    "sys_one_zero",
    "sys_sample_status",
    "sys_sample_name",
    "sys_sample_cj",
    "sys_jst_sample_sf",
  ],
  components: {
    clickcontact,
    byProductNo,
  },
  data() {
    return {
      //直播间
      liveRoomNameStatus: 0,
      liveRoomName: "",
      liveroomList: [],
      isByProductNo: false,

      isEdit: false,
      iscontactList: false,
      count: 1,
      sizeArr: [],
      //库存量
      num: "",
      demo: "",
      //省市区
      pcaaData: pcaa,
      // 区域数据
      provinces: pcaa["86"],
      citys: [],
      areas: [],
      //
      productNo: "",
      colorProperty: "",
      size: "",
      // 遮罩层
      loading: true,
      //模糊匹配
      sizeList: [],
      ColorLike: [],
      options: [], // 选项，从后端传递过来
      sampleTalentCooperateType: "",
      expressCompany: "中通快递",
      //data
      noticForm: {
        noticConfig: [
          {
            name: [
              {
                // value: "",
                // phone: "",
                productNo: "",
                colorProperty: "",
                size: "",
                productNum: "",
                isReturn: "是",
                id: 0,

                // expressCompany: "",
              },
            ],
            // phone: [
            //     {
            //         value: "",
            //     },
            // ],
          },
        ],
      },

      sampleTalentContact: {
        phone: "",
        receiverCity: "",
        receiverDistrict: "",
        receiverState: "",
        recipient: "",
        address: "",
      },
      sampleTalentInfo: {
        platform: "",
        platformId: "",
        talentLevel: "",
        xhsNickname: "",
        contactPerson: "",
        recommendSituation: "",
        reason: "",
        homeLink: "",
        fansNum: "",
        likeNum: "",
        cooperatePrice: "",
        talentStatus: "",
        contactWechat: "",
      },
      sampleTalentPay: {
        payAccount: "",
        payImage: "",
        payMethod: "",
        payName: "",
        platform: "",
      },

      // 表单校验
      rules: {
        productNo: [
          { required: true, message: "货号不能为空", trigger: "blur" },
        ],
        colorProperty: [
          { required: true, message: "颜色不能为空", trigger: "blur" },
        ],
        size: [{ required: true, message: "尺寸不能为空", trigger: "blur" }],
        // productNum: [
        //     { required: true, message: "数量不能为空", trigger: "blur" }
        // ],
        // platform: [
        //     { required: true, message: "平台名称不能为空", trigger: "blur" }
        // ],
        // platformId: [
        //     { required: true, message: "平台ID不能为空", trigger: "blur" }
        // ],
        // xhsNickname: [
        //     { required: true, message: "昵称不能为空", trigger: "blur" }
        // ],
        // phone: [
        //     { required: true, message: "电话不能为空", trigger: "blur" }
        // ],
      },
    };
  },
  created() {
    listLiveroom({
      pageNum: 1,
      pageSize: 100,
    }).then((response) => {
      this.liveroomList = response.rows;
      // this.total = response.total;
      // this.loading = false;
    });
    // this.provincearr = province
    // this.getList();
  },
  methods: {
    handleSampleInfo() {
      this.sampleTalentContact = {
        phone: "",
        receiverCity: "",
        receiverDistrict: "",
        receiverState: "",
        recipient: "",
        address: "",
        id: "",
      };
      this.sampleTalentInfo = {
        platform: "",
        platformId: "",
        talentLevel: "",
        xhsNickname: "",
        contactPerson: "",
        recommendSituation: "",
        reason: "",
        homeLink: "",
        fansNum: "",
        likeNum: "",
        cooperatePrice: "",
        talentStatus: "",
        contactWechat: "",
        id: "",
      };

      this.isEdit = false;
    },
    trackingNumberHandle(row) {
      this.iscontactList = false;
      this.isEdit = true;
      console.log(JSON.stringify(row.sampleTalentInfoId));
      this.sampleTalentContact = {
        phone: row.phone,
        receiverCity: row.receiverCity,
        receiverDistrict: row.receiverDistrict,
        receiverState: row.receiverState,
        recipient: row.recipient,
        address: row.address,
        id: row.id,
      };

      this.sampleTalentInfo.platform = row.platform;
      this.sampleTalentInfo.platformId = row.platformId;
      this.sampleTalentInfo.xhsNickname = row.xhsNickname;
      this.sampleTalentInfo.id = row.sampleTalentInfoId;
    },
    //{"createBy":"1","createTime":"2024-05-25 21:58:51","updateBy":"","updateTime":null,"remark":null,"id":399,"sampleTalentInfoId":288,"platformId":"888321","phone":"15888888888","recipient":"李先生","address":"坂田华为基地F区","isDelete":0,"platform":"私域","xhsNickname":"888321","receiverState":"广东省","receiverCity":"深圳市","receiverDistrict":"龙岗区"}
    // addText() {
    //   if (!this.demo) {
    //     this.$modal.msgError("请输入内容");
    //     return;
    //   }

    //   let address = this.demo.replace(/\s+/g, " ");
    //   console.log(JSON.stringify(address));
    //   axios({
    //     method: "get",
    //     url: "https://v.api.aa1.cn/api/api-kdjx/index.php",
    //     params: {
    //       msg: address,
    //     },
    //   }).then((res) => {
    //     console.log(JSON.stringify(res.data));
    //     let m = res.data.newslist[0];
    //     this.sampleTalentContact.phone = m.mobile ? m.mobile : "";
    //     this.sampleTalentContact.recipient = m.name ? m.name : "";
    //     this.sampleTalentContact.receiverState = m.province ? m.province : "";
    //     this.sampleTalentContact.receiverCity = m.city ? m.city : "";
    //     this.sampleTalentContact.receiverDistrict = m.district
    //       ? m.district
    //       : "";
    //     this.sampleTalentContact.address = m.detail;

    //     this.seletekey(this.sampleTalentContact.receiverState, "province");
    //     this.seletekey(this.sampleTalentContact.receiverCity, "city");
    //     this.seletekey(this.sampleTalentContact.receiverDistrict, "area");
    //   });
    // },
    addText() {
      if (!this.demo) {
        this.$modal.msgError("请输入内容");
        return;
      }

      let address = this.demo.replace(/\s+/g, " ");
      console.log(JSON.stringify(address));
      const result = AddressParse.parse(address);
      this.sampleTalentContact.phone = result[0].mobile ? result[0].mobile : "";
      this.sampleTalentContact.recipient = result[0].name ? result[0].name : "";
      this.sampleTalentContact.receiverState = result[0].province
        ? result[0].province
        : "";
      this.sampleTalentContact.receiverCity = result[0].city
        ? result[0].city
        : "";
      this.sampleTalentContact.receiverDistrict = result[0].area
        ? result[0].area
        : "";
      this.sampleTalentContact.address = result[0].details;

      this.seletekey(this.sampleTalentContact.receiverState, "province");
      this.seletekey(this.sampleTalentContact.receiverCity, "city");
      this.seletekey(this.sampleTalentContact.receiverDistrict, "area");

      let obj = {
        fullAddress: this.demo,
        province: this.sampleTalentContact.receiverState,
        city: this.sampleTalentContact.receiverCity,
        district: this.sampleTalentContact.receiverDistrict,
        detailedAddress: this.sampleTalentContact.address,

        recipientPhone: this.sampleTalentContact.phone,
        recipientName: this.sampleTalentContact.recipient,
      };

      axios({
        method: "post",
        url: "http://47.107.129.160:9001/prod-api/product/parsing",
        // url: "http://47.97.123.182:1399/smAddress",
        data: obj,
      }).then((response) => {});
      //   this.sampleTalentContact.phone = res.data.phone ? res.data.phone : "";
      //   this.sampleTalentContact.recipient = res.data.name ? res.data.name : "";
      //   this.sampleTalentContact.receiverState = res.data.province
      //     ? res.data.province
      //     : "";
      //   this.sampleTalentContact.receiverCity = res.data.city
      //     ? res.data.city
      //     : "";
      //   this.sampleTalentContact.receiverDistrict = res.data.county
      //     ? res.data.county
      //     : "";
      //   this.sampleTalentContact.address = res.data.street
      //     ? res.data.street + res.data.address
      //     : res.data.address;

      //   this.seletekey(this.sampleTalentContact.receiverState, "province");
      //   this.seletekey(this.sampleTalentContact.receiverCity, "city");
      //   this.seletekey(this.sampleTalentContact.receiverDistrict, "area");
      // });
    },
    testsampleTalentCooperateType(val) {
      console.log(val);
      this.sampleTalentCooperateType = val;
    },

    submitlive() {
      if (!this.sampleTalentInfo.platform) {
        this.$modal.msgError("请输入平台名称");
        return;
      }
      if (!this.sampleTalentInfo.platformId) {
        this.$modal.msgError("请输入平台ID");
        return;
      }
      if (!this.sampleTalentInfo.xhsNickname) {
        this.$modal.msgError("请输入昵称");
        return;
      }
      if (!this.sampleTalentContact.phone) {
        this.$modal.msgError("请输入电话");
        return;
      }
      if (!this.sampleTalentContact.recipient) {
        this.$modal.msgError("请输入收件人");
        return;
      }
      if (!this.sampleTalentContact.receiverState) {
        this.$modal.msgError("请选择省份");
        return;
      }
      if (!this.sampleTalentContact.receiverCity) {
        this.$modal.msgError("请选择城市");
        return;
      }
      if (!this.sampleTalentContact.receiverDistrict) {
        this.$modal.msgError("请选择县区");
        return;
      }
      if (!this.sampleTalentContact.address) {
        this.$modal.msgError("请输入详细地址");
        return;
      }
      if (this.liveRoomNameStatus == 0) {
        this.liveRoomName = "非直播间申请";
      }
      // == 'live'
      console.log(this.sampleTalentCooperateType);
      // if (!this.sampleTalentCooperateType.includes('live')) {
      //     this.$modal.msgError('请选择直播类型')
      //     return
      // }
      // return
      console.log(JSON.stringify(this.noticForm.noticConfig));

      // this.noticForm.noticConfig.forEach(item => {
      //     note.push(item.name)
      // })
      var apply = this.noticForm.noticConfig.map((item) => item.name[0]);
      var live = [];
      apply.forEach((item) => {
        live.push({
          liveRoomName: this.liveRoomName,
          expressCompany: this.expressCompany,
          ...item,
        });
      });

      console.log(JSON.stringify(live));
      var liveList = {
        sampleTalentCooperateType: "live",
        sampleTalentApplyVOList: live,
        sampleTalentContact: { ...this.sampleTalentContact },
        sampleTalentInfo: { ...this.sampleTalentInfo },
        sampleTalentPay: { ...this.sampleTalentPay },
      };
      if (!liveList.sampleTalentApplyVOList[0].productNo) {
        this.$modal.msgError("请选择款式");
        return;
      }
      // if (!liveList.sampleTalentApplyVOList[0].colorProperty) {

      //     this.$modal.msgError('请选择颜色')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].size) {

      //     this.$modal.msgError('请选择尺寸')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].productNum) {

      //     this.$modal.msgError('请输入数量')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].isReturn) {

      //     this.$modal.msgError('请选择是否归还')
      //     return
      // }
      if (liveList.sampleTalentApplyVOList[1]) {
        if (!liveList.sampleTalentApplyVOList[1].productNo) {
          this.$modal.msgError("请选择第二个款式");
          return;
        }
      }

      // return
      console.log(JSON.stringify(liveList));
      SampleTalentFirstAdd(liveList).then((res) => {
        console.log(res);
        if (res.msg == "操作完成！") {
          this.$modal.msgSuccess("操作完成");
          // this.data = {};
          // window.location.reload();
          //清空数据
          this.resetForm();
          this.$router.push({
            path: "/sample/sampleApply",
            // query: { platformId: this.sampleTalentInfo.platformId },
          });
          // location.reload();
        } else {
          this.$modal.msgError(res.msg);
        }
      });
    },
    handleProductInfo() {
      this.noticForm = {
        noticConfig: [
          {
            name: [
              {
                productNo: "",
                colorProperty: "",
                size: "",
                productNum: "",
                isReturn: "是",
                id: 0,
              },
            ],
          },
        ],
      };
      this.isEdit = false;
    },
    resetForm() {
      this.noticForm = {
        noticConfig: [
          {
            name: [
              {
                productNo: "",
                colorProperty: "",
                size: "",
                productNum: "",
                isReturn: "是",
                id: 0,
              },
            ],
          },
        ],
      };
      this.sampleTalentContact = {};
      this.sampleTalentInfo = {};
      this.sampleTalentPay = {};
      this.isEdit = false;
      this.liveRoomNameStatus = 0;
    },
    submitnote() {
      if (!this.sampleTalentInfo.platform) {
        this.$modal.msgError("请输入平台名称");
        return;
      }
      if (!this.sampleTalentInfo.platformId) {
        this.$modal.msgError("请输入平台ID");
        return;
      }
      if (!this.sampleTalentInfo.xhsNickname) {
        this.$modal.msgError("请输入昵称");
        return;
      }
      if (!this.sampleTalentContact.phone) {
        this.$modal.msgError("请输入电话");
        return;
      }
      if (!this.sampleTalentContact.recipient) {
        this.$modal.msgError("请输入收件人");
        return;
      }
      if (!this.sampleTalentContact.receiverState) {
        this.$modal.msgError("请选择省份");
        return;
      }
      if (!this.sampleTalentContact.receiverCity) {
        this.$modal.msgError("请选择城市");
        return;
      }
      if (!this.sampleTalentContact.receiverDistrict) {
        this.$modal.msgError("请选择县区");
        return;
      }
      if (!this.sampleTalentContact.address) {
        this.$modal.msgError("请输入详细地址");
        return;
      }

      // if (!this.sampleTalentPay.payMethod) {

      // this.$modal.msgError('请输入支付方式')
      // return
      // }
      // if (!this.sampleTalentPay.payMethod) {

      // this.$modal.msgError('请输入支付方式')
      // return
      // }
      // if (!this.sampleTalentPay.payMethod) {

      //     this.$modal.msgError('请输入支付方式')
      //     return
      // }
      // if (!this.sampleTalentPay.payMethod) {

      //     this.$modal.msgError('请输入支付方式')
      //     return
      // }
      // if (!this.sampleTalentCooperateType.includes('note')) {
      //     this.$modal.msgError('请选择笔记类型')
      //     return
      // }
      // var apply = this.noticForm.noticConfig.map(item => item.name[0])
      var apply = this.noticForm.noticConfig.map((item) => item.name[0]);
      console.log(JSON.stringify(apply));
      var live = [];
      apply.forEach((item) => {
        live.push({ expressCompany: this.expressCompany, ...item });
      });

      var liveList = {
        sampleTalentCooperateType: "note",
        sampleTalentApplyVOList: live,
        sampleTalentContact: { ...this.sampleTalentContact },
        sampleTalentInfo: { ...this.sampleTalentInfo },
        sampleTalentPay: { ...this.sampleTalentPay },
      };
      console.log(JSON.stringify(liveList));
      if (!liveList.sampleTalentApplyVOList[0].productNo) {
        this.$modal.msgError("请选择款式");
        return;
      }
      // if (!liveList.sampleTalentApplyVOList[0].colorProperty) {

      //     this.$modal.msgError('请选择颜色')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].size) {

      //     this.$modal.msgError('请选择尺寸')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].productNum) {

      //     this.$modal.msgError('请输入数量')
      //     return
      // }
      // if (!liveList.sampleTalentApplyVOList[0].isReturn) {

      //     this.$modal.msgError('请选择是否归还')
      //     return
      // }
      if (liveList.sampleTalentApplyVOList[1]) {
        if (!liveList.sampleTalentApplyVOList[1].productNo) {
          this.$modal.msgError("请选择第二个款式");
          return;
        }
      }
      // return
      SampleTalentFirstAdd(liveList).then((res) => {
        console.log(res);
        if (res.msg == "操作完成！") {
          this.$modal.msgSuccess("操作完成");
          this.$router.push({
            path: "/sample/sample",
            // query: { platformId: this.sampleTalentInfo.platformId },
          });
        } else {
          this.$modal.msgError(res.msg);
        }
      });
    },

    // 新增
    removeDomain(item) {
      var index = this.noticForm.noticConfig.indexOf(item);
      if (index == "0") {
        // 还有一个的时候提示不能删除
        this.$message({
          message: "不能删除了",
          type: "error",
        });
        return false;
      }
      if (index !== -1 && index !== "0") {
        this.noticForm.noticConfig.splice(index, 1);
      }
    },
    // 表单新增
    addDomain(item) {
      console.log(
        JSON.stringify(this.noticForm.noticConfig[0].name[0].isReturn)
      );
      var m = item.name[0];
      if (!m.productNo) {
        this.$modal.msgError("请选择款式");
        return;
      }
      if (!m.colorProperty) {
        this.$modal.msgError("请选择颜色");
        return;
      }
      if (!m.size) {
        this.$modal.msgError("请选择尺寸");
        return;
      }
      if (!m.productNum) {
        this.$modal.msgError("请输入数量");
        return;
      }
      if (!m.isReturn) {
        this.$modal.msgError("请选择是否归还");
        return;
      }
      // var i = 0
      // if(m.isReturn){

      // }
      this.noticForm.noticConfig.push({
        name: [
          {
            // value: "",

            // phone: "",
            productNo: "",
            colorProperty: "",
            size: "",
            productNum: "",
            isReturn: this.noticForm.noticConfig[0].name[0].isReturn,
            id: this.count++,
            publicCanUseNum: "",
            // num: "",
            // expressCompany: "",
            key: Date.now(),
            isEdit: false,
          },
        ],
        // phone: [
        //     {
        //         value: "",
        //         key: Date.now() + "2",
        //     },
        // ],
      });
    },
    //追加到合作款式列表
    getinventoryByProductNo(list) {
      console.log(JSON.stringify(list));

      var apply = this.noticForm.noticConfig.map((item) => item.name[0]);
      if (!apply[0].productNo) {
        this.noticForm.noticConfig = [];
      }
      list.forEach((item) => {
        this.noticForm.noticConfig.push({
          name: [
            {
              // value: "",

              // phone: "",
              productNo: item.productNo,
              colorProperty: item.colorProperty,
              size: item.size,
              productNum: "",
              publicCanUseNum: item.publicCanUseNum,
              isReturn: "是",
              id: this.count++,
              isEdit: true,

              // num: "",
              // expressCompany: "",
              key: Date.now(),
            },
          ],
          // phone: [
          //     {
          //         value: "",
          //         key: Date.now() + "2",
          //     },
          // ],
        });
        // this.sizeArr.push(item.publicCanUseNum );
      });
      this.isByProductNo = false;
    },
    getinput() {
      console.log(JSON.stringify(this.noticForm.noticConfig));
    },
    //修改对话框
    /* 获取颜色列表 */
    getSize(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      // listAll({ productNo: this.form.productNo, colorProperty: this.form.colorProperty }).then((res) => {
      //     // this.loading = false;
      //     this.sizeList = res
      //     console.log(JSON.stringify(res));
      // });
    },

    /* 获取颜色列表 */
    getData(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      // colorLike(key).then((res) => {
      //     // this.loading = false;
      //     this.ColorLike = res.data;
      //     console.log(JSON.stringify(this.ColorLike));
      // });
    },
    getinventory() {
      inventory({
        productNo: this.productNo,
        colorProperity: this.colorProperty,
        size: this.form.size,
      }).then((res) => {
        // console.log(JSON.stringify(res.data));
        if (res.code == 200) {
          this.num = res.data[0].virtual_qty;
        } else {
          this.$modal.msgError(res.msg);
        }
      });
    },
    testNum(index) {
      // this.num = JSON.parse(localStorage.getItem("num"))
    },
    // 打开加载层
    openLoading() {
      this.$modal.loading("正在加载库存，请稍候！");
    },
    testSize(nameItem) {
      console.log(JSON.stringify(nameItem));
      this.openLoading();
      inventory({
        productNo: nameItem.productNo,
        colorProperity: nameItem.colorProperty,
        size: nameItem.size,
      }).then((res) => {
        this.$modal.closeLoading();
        if (res.code == 200) {
          if (res.data.length > 0) {
            nameItem.publicCanUseNum = res.data[0].publicCanUseNum;

            this.$forceUpdate();
          } else {
            this.$modal.msgError("该商品编码聚水潭不存在，请核对。");
          }
        } else {
          this.$modal.msgError(res.msg);
        }
      });
      return;
      console.log(JSON.stringify(key));
      this.size = key;
      // console.log(this.count);
      console.log(index);
      inventory({
        productNo: this.productNo,
        colorProperity: this.colorProperty,
        size: this.size,
      }).then((res) => {
        if (res.code == 200) {
          if (res.data.length > 0) {
            this.sizeArr[index] = res.data[0].publicCanUseNum;
            console.log(JSON.stringify(this.sizeArr[index]));
            console.log(JSON.stringify(this.sizeArr));
            this.$forceUpdate();
          } else {
            this.$modal.msgError("该商品编码聚水潭不存在，请核对。");
          }
        } else {
          this.$modal.msgError(res.msg);
        }
      });
    },
    /* 获取尺寸列表 */
    testColor(key) {
      this.colorProperty = key;
      listAll({ productNo: this.productNo, colorProperty: key }).then((res) => {
        // this.loading = false;
        this.sizeList = res;
        console.log(JSON.stringify(res));
      });
    },
    /* 获取颜色列表 */
    testAdd(key) {
      this.productNo = key;
      console.log();
      productNoColorLike({ productNo: key }).then((res) => {
        // this.loading = false;
        this.ColorLike = res.data;
        console.log(JSON.stringify(this.ColorLike));
      });
    },

    /* 获取货号列表 */
    getDatas(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.options = res.data;
        console.log(JSON.stringify(this.options));
      });
    },
    //修改对话框
    //添加颜色列表获得焦点
    onFocus() {
      this.getData();

      this.getSize();
      // if (!this.form.colorProperty) {
      //     this.$selectRef.value.blur() //就是这一句，
      // }
    },
    seletekey(e, type) {
      if (e) {
        switch (type) {
          case "province":
            Object.keys(this.provinces).filter((item) => {
              if (this.provinces[item] === e) {
                this.citys = this.pcaaData[item];
              }
            });
            break;
          case "city":
            Object.keys(this.citys).filter((item) => {
              if (this.citys[item] === e) {
                this.areas = this.pcaaData[item];
              }
            });
            break;
          case "area":
            this.sampleTalentContact.receiverDistrict = e;
            this.$forceUpdate();
            break;
        }
      }
    },
  },
};
</script>
